package com.itqf.Controller;

import com.itqf.Enum.CodeEnum;
import com.itqf.Service.Topicsynthesis.TopicsynthesisService;
import com.itqf.Util.DTO.ResultDTO;
import com.itqf.entity.Subject;
import com.itqf.entity.Topicstage;
import com.itqf.entity.Topicsynthesis;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class TopicsynthesisController {
    //查询各科详细描述
    @Resource
    private TopicsynthesisService topicsynthesisService;
    //请求路经/huileme/a/u/practiceRoom
    @RequestMapping(value = "/huileme/a/m/TopicsynthesisController/practiceRoom",method = RequestMethod.GET)
    @ResponseBody
    public ResultDTO<Map> practiceRoom() {
        Map map=new HashMap();
        //获得年级科目综合信息
        ResultDTO resultDTO=new ResultDTO();
        List<Topicsynthesis> topicsynthesisList = topicsynthesisService.findtopicsynthesisList();
        map.put("topicsynthesisList",topicsynthesisList);
        //获得科目集合
        List<Subject> subjectListList = topicsynthesisService.findsubjectlist();
        map.put("subjectListList",subjectListList);
        //获得年级集合
        List<Topicstage> topicstageList = topicsynthesisService.findtopicstageList();
        map.put("topicstageList",topicstageList);

        if (!topicstageList.isEmpty()&&!subjectListList.isEmpty()&&!topicstageList.isEmpty())
        {
            resultDTO.setCode(CodeEnum.selectsuccess.getCode());
            resultDTO.setMessage(CodeEnum.selectsuccess.getMsg());
            resultDTO.setData(map);
        }else
        {
            resultDTO.setCode(CodeEnum.selecterror.getCode());
            resultDTO.setMessage(CodeEnum.selecterror.getMsg());
        }

        return resultDTO;
}
}
